﻿using System;
using System.Text;
using System.Net.Sockets;
using System.Net;
using HammerMUD.System;

namespace HammerMUDServer
{
    public class Server
    {
        private const int PortNumber = 80;
        private const int BacklogSize = 20;
        private static HammerMUD.System.HammerMUD system;

        public static void Main(string[] args)
        {
            Socket server, conn;

            system = new HammerMUD.System.HammerMUD();

            server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            server.Bind(new IPEndPoint(IPAddress.Any, PortNumber));
            server.Listen(BacklogSize);

            Console.WriteLine("Welcome to HammerMUD");
            Console.WriteLine("");
            Console.WriteLine("Waiting for clients...");

            while (true)
            {
                conn = server.Accept();
                new Connection(conn, system);
            }
        }
    }
}
